<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
</head>

<body>
  <div id="app">
    <h2>今天的天气是{{isHot?"晴天":"雨天"}}</h2>
    <button v-on:click="changeWeather">点击切换天气</button>
    <hr />
    <h1>数据是{{num}}</h1>
    <button @click="addnum(1)">点击累加1</button>
    <button @click="addnum(1)">点击累加2</button>
    <button @click="num+=3">点击累加3</button>
    <hr>
    <h1>输入框里面的内容为{{message}}</h1>
    <input type="text" @input="message=$event.target.value">

    <hr>
    <h1>输入框里面的内容为{{messages}}(失去焦点)</h1>
    <input type="text" @blur="getmessage($event)">
  </div>
  <script>
    const vm = new Vue({
      el: "#app",
      data() {
        return {
          isHot: true,
          num: 0,
          message: "",
          messages: ""

        };
      },
      methods: {
        changeWeather() {
          this.isHot = !this.isHot;
        },
        addnum(n) {
          this.num += n;
        },
        getmessage(e) {
          this.messages = e.target.value;
        }
      }
    })
  </script>
</body>

</html>